<?php

	class My_Plugin_Test extends Zend_Controller_Plugin_Abstract
	{
			private $_action = null;
			private $_i = 0;
			
		public function routeStartup(Zend_Controller_Request_Abstract $request)
		{
		    $this->getResponse()
		         ->appendBody("
		         	<p>routeStartup() called " .
		         	'dispatched ' . (($request->isDispatched()) ? 'yes': 'no') .'<br />
		         	'. $request->getActionName() .'
		       	');
		}
		
		public function routeShutdown(Zend_Controller_Request_Abstract $request)
		{
		    $this->getResponse()
		         ->appendBody("
		         	<p>routeShutdown() called " .
		         	'dispatched ' . (($request->isDispatched()) ? 'yes': 'no') .'<br />
		         	'. $request->getActionName() .'
		       	');
		}
		
		public function dispatchLoopStartup(Zend_Controller_Request_Abstract $request)
		{
		    $this->getResponse()
		         ->appendBody("
		         	<p>dispatchLoopStartup() called " .
		         	'dispatched ' . (($request->isDispatched()) ? 'yes': 'no') .'<br />
		         	'. $request->getActionName() .'
		       	');
		}
		
		public function preDispatch(Zend_Controller_Request_Abstract $request)
		{
			
		    $this->getResponse()
		         ->appendBody("
		         	<p>preDispatch() called " .
		         	'dispatched ' . (($request->isDispatched()) ? 'yes': 'no') .'<br />
		         	'. $request->getActionName() .' i: ' . $this->_i .'
		       	');
		         	
		         	if ( ($this->_action != 'error') || ($this->_action != null ) ) {
		         		$this->getResponse()->appendBody('ikinci kezzz');
		         	}
		         	if ($this->_action == null) {
		         		$this->_action = $request->getActionName();
		         		//$request->setDispatched(true);
		         	}
		         	$request->setModuleName($request->getModuleName())
				        ->setControllerName($request->getControllerName())
				        ->setActionName($request->getActionName())
				        ;

			$this->_i++;
		         	
		}
		
		public function postDispatch(Zend_Controller_Request_Abstract $request)
		{
		    $this->getResponse()
		         ->appendBody("
		         	<p>postDispatch() called " .
		         	'dispatched ' . (($request->isDispatched()) ? 'yes': 'no') .'<br />
		         	'. $request->getActionName() .'
		       	');
		         	
//         	if ($request->isDispatched() != true) {
//     			$request->setDispatched(false);
//         	}
		}
		
		public function dispatchLoopShutdown()
		{
		    $this->getResponse()
		         ->appendBody("
		         	<p>dispatchLoopShutdown() called
		       	");
		}

	}
	